<!DOCTYPE html>
<html>
<head>
    <title>Telephoto Lens System</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        canvas {
            border: 1px solid #ccc;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <canvas id="physicsCanvas" width="600" height="400"></canvas>
    <script>
        const canvas = document.getElementById('physicsCanvas');
        const ctx = canvas.getContext('2d');

        // Style settings
        ctx.strokeStyle = 'black';
        ctx.fillStyle = 'black';
        ctx.lineWidth = 2;

        // Coordinates and dimensions
        const y_axis = 180;
        const x1 = 140; // x-position of lens L1
        const x2 = 290; // x-position of lens L2
        const x_film = 490; // x-position of film
        const lens_h = 70; // half-height of lenses
        const film_h = 80; // half-height of film line
        const y_dim = 280; // y-position for dimension lines

        // --- Draw Principal Axis ---
        ctx.beginPath();
        ctx.moveTo(40, y_axis);
        ctx.lineTo(560, y_axis);
        ctx.stroke();

        // --- Draw Lens L1 (Converging) ---
        const l1_bulge = 22;
        ctx.beginPath();
        // Left curve
        ctx.moveTo(x1, y_axis - lens_h);
        ctx.quadraticCurveTo(x1 - l1_bulge, y_axis, x1, y_axis + lens_h);
        // Right curve
        ctx.moveTo(x1, y_axis - lens_h);
        ctx.quadraticCurveTo(x1 + l1_bulge, y_axis, x1, y_axis + lens_h);
        ctx.stroke();

        // Vertical line for L1
        ctx.beginPath();
        ctx.moveTo(x1, y_axis - lens_h - 20);
        ctx.lineTo(x1, y_axis + lens_h);
        ctx.stroke();
        
        // Label L1
        ctx.font = '20px Arial';
        ctx.textAlign = 'center';
        ctx.textBaseline = 'bottom';
        ctx.fillText('L₁', x1, y_axis - lens_h - 25);

        // --- Draw Lens L2 (Diverging) ---
        const l2_w_top = 20;
        const l2_w_center = 4;
        ctx.beginPath();
        ctx.moveTo(x2 - l2_w_top, y_axis - lens_h);
        ctx.lineTo(x2 + l2_w_top, y_axis - lens_h);
        ctx.quadraticCurveTo(x2 + l2_w_center, y_axis, x2 + l2_w_top, y_axis + lens_h);
        ctx.lineTo(x2 - l2_w_top, y_axis + lens_h);
        ctx.quadraticCurveTo(x2 - l2_w_center, y_axis, x2 - l2_w_top, y_axis - lens_h);
        ctx.stroke();
        
        // Vertical line for L2
        ctx.beginPath();
        ctx.moveTo(x2, y_axis - lens_h - 20);
        ctx.lineTo(x2, y_axis + lens_h);
        ctx.stroke();
        
        // Label L2
        ctx.fillText('L₂', x2, y_axis - lens_h - 25);

        // --- Draw Film Plane ---
        ctx.beginPath();
        ctx.moveTo(x_film, y_axis - film_h - 10);
        ctx.lineTo(x_film, y_axis + film_h + 10);
        ctx.stroke();
        
        // Label Film
        ctx.fillText('film', x_film, y_axis - film_h - 15);

        // --- Draw Dimension Lines ---
        const arrowSize = 8;
        const tickHeight = 12;
        ctx.lineWidth = 1.5;
        ctx.font = 'bold 18px Arial';
        
        // Helper function to draw one dimension segment
        function drawDimension(x_start, x_end, label) {
            ctx.beginPath();
            // Horizontal line
            ctx.moveTo(x_start, y_dim);
            ctx.lineTo(x_end, y_dim);

            // Left arrow
            ctx.moveTo(x_start + arrowSize, y_dim - arrowSize / 2);
            ctx.lineTo(x_start, y_dim);
            ctx.lineTo(x_start + arrowSize, y_dim + arrowSize / 2);

            // Right arrow
            ctx.moveTo(x_end - arrowSize, y_dim - arrowSize / 2);
            ctx.lineTo(x_end, y_dim);
            ctx.lineTo(x_end - arrowSize, y_dim + arrowSize / 2);
            
            ctx.stroke();

            // Label
            ctx.textAlign = 'center';
            ctx.textBaseline = 'bottom';
            ctx.fillText(label, (x_start + x_end) / 2, y_dim - 5);
        }
        
        // Draw dimensions
        drawDimension(x1, x2, '20 mm');
        drawDimension(x2, x_film, 'x');
        
        // Draw ticks for dimension lines
        ctx.beginPath();
        ctx.moveTo(x1, y_dim - tickHeight / 2);
        ctx.lineTo(x1, y_dim + tickHeight / 2);
        ctx.moveTo(x2, y_dim - tickHeight / 2);
        ctx.lineTo(x2, y_dim + tickHeight / 2);
        ctx.moveTo(x_film, y_dim - tickHeight / 2);
        ctx.lineTo(x_film, y_dim + tickHeight / 2);
        ctx.stroke();
        
        // --- Draw Figure Caption ---
        ctx.font = 'bold 20px "Times New Roman"';
        ctx.textAlign = 'center';
        ctx.textBaseline = 'bottom';
        ctx.fillText('Fig. 1.43', canvas.width / 2, canvas.height - 20);

    </script>
</body>
</html>